package sk.naive.talker.command;

import sk.naive.talker.props.*;
import sk.naive.talker.*;
import sk.naive.talker.util.Utils;

import java.rmi.RemoteException;

/**
 *
 * @author <a href="mailto:rytier@naive.deepblue.sk">Martin "Rytier" Kerni</a>
 * @version $Revision: 1.12 $ $Date: 2005/01/19 22:41:27 $
 */
public class Review extends ReviewCommand {
	public static final String TPROP_SAY_REVIEW = "sayReview";

	public void exec()
		throws CommandException, RemoteException, PropertyStoreException
	{
		Location loc = new LocationHelper(commandDispatcher).locationForUser(user);
		if (loc == null && params == null) {
			sendHelper().sendMessage(user, "message.noRoom");
			return;
		}
		super.exec();
	}

	public PropertyStore getReviewStore(User user, String params) {
		if (params != null && params.length() > 0 && Utils.ownsPermission(user, Consts.PERM_SUPERUSER)) {
			Location loc = new LocationHelper(commandDispatcher).locationForName(params);
			if (loc != null) {
				return loc;
			}
		}
		return new LocationHelper(commandDispatcher).locationForUser(user);
	}

	public String getReviewPropertyName() {
		return TPROP_SAY_REVIEW;
	}

	public String getReviewEmptyMessageKey() {
		return "review.empty";
	}

	public String getReviewHeadMessageKey() {
		return "review.head";
	}

	public String getReviewTailMessageKey() {
		return "review.tail";
	}
}
